﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using StudioLib;
namespace StuCat
{
    public partial class PictureBoxComment : UserControl
    {
        Photo currentPhoto;
        public PictureBoxComment()
        {
            InitializeComponent();
        }

        public void LoadPhoto(Photo photo)
        {
            currentPhoto = photo;

            picBox.Image = photo.Data;
            textBox1.Text = photo.Comment;

            if (picBox.Image.Height > picBox.Image.Width)
            {
                float k = ((float)picBox.Image.Height / 240);
                this.Height = 240 + textBox1.Height;
                this.Width = (int)(picBox.Image.Width / k);
            }
            else
            {
                float k = ((float)picBox.Image.Width / 320);
                this.Width = 320;
                this.Height = (int)(picBox.Image.Height / k) + textBox1.Height;
            }
            picBox.Height = this.Height - textBox1.Height;
            picBox.SizeMode = PictureBoxSizeMode.StretchImage;

        }


        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if ((currentPhoto.Data.Height > picBox.Height) || (currentPhoto.Data.Width > picBox.Width))
            {
                LargePhotoBox box = new LargePhotoBox();
                box.LoadImage(currentPhoto.Data);
                
                box.ShowDialog();
            }
        }

     
    }
}
